﻿using System;
using JetBrains.Annotations;
using JetBrains.DocumentModel;
using JetBrains.ReSharper.Daemon;
using JetBrains.ReSharper.Daemon.Impl;
using JetBrains.ReSharper.Psi.Xaml.Impl.Tree;

namespace GammaJul.ReSharper.GammaXaml.Highlightings.Xaml {

	/// <summary>
	/// Base highlighting for XAML setters that can be removed.
	/// </summary>
	public abstract class DeadCodeSetterHighlightingBase : IHighlightingWithRange {
		 private readonly IPropertySetter _propertySetter;

		[NotNull]
		public IPropertySetter PropertySetter {
			get { return _propertySetter; }
		}

		public abstract string ToolTip { get; }

		public string ErrorStripeToolTip {
			get { return ToolTip; }
		}

		public int NavigationOffsetPatch {
			get { return 0; }
		}

		public virtual bool IsValid() {
			return _propertySetter.IsValid();
		}

		public DocumentRange CalculateRange() {
			return _propertySetter.GetHighlightingRange();
		}

		protected DeadCodeSetterHighlightingBase([NotNull] IPropertySetter propertySetter) {
			if (propertySetter == null)
				throw new ArgumentNullException("propertySetter");

			_propertySetter = propertySetter;
		}
	}

}